<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new ProfileCtl();
	$ctl->checkLogged();
	$ctl->checkNotReadonly();
	$ctl->proceed();
	
	$header = new Header();
	$header->render('User Profile');

	$form = $ctl->getProfileForm();
	
	$login = $form->getLogin();
	$name = $form->getName();
	
	$admin = $form->isAdmin() ? 'yes' : '';
	$lblAdmin = $form->isAdmin() ? 'Yes' : 'No';
	$clsAdmin = $form->isAdmin() ? 'yes' : 'no'; // the class to be attached to the TD
	
	$connect = $form->isConnect() ? 'yes' : '';
	$lblConnect = $form->isConnect() ? 'Yes' : 'No';
	$clsConnect = $form->isConnect() ? 'yes' : 'no'; // the class to be attached to the TD
	
	$sendEmail = $form->isSendEmail() ? 'checked' : '';
	$email = $form->getEmail();
	
?>
<form method="post">
<input type="hidden" name="pagename" value="profile" id="pgid">
<input type="hidden" name="metname" value="" id="metid">

<input type="hidden" name="admin" value="<?php echo $admin; ?>" >
<input type="hidden" name="connect" value="<?php echo $connect; ?>">

<h2>User Profile</h2>
<p>Please update your personal information, then press submit.</p>

<table cellpadding="4" cellspacing="0" class="list">
	<tr>
		<td nowrap>Login:</td>
		<td nowrap><input type="text" name="login" value="<?php echo $login; ?>" ></td>
	</tr>
	<tr>
		<td nowrap>Name:</td>
		<td nowrap><input type="text" name="name" value="<?php echo $name; ?>" ></td>
	</tr>
	<tr>
		<td nowrap>Admin:</td>
		<td nowrap class="<?php echo $clsAdmin; ?>"><?php echo $lblAdmin?></td>
	</tr>
	<tr>
		<td nowrap>Connect:</td>
		<td nowrap class="<?php echo $clsConnect; ?>"><?php echo $lblConnect; ?></td>
	</tr>
	<tr>
		<td nowrap>Email:</td>
		<td nowrap><input type="text" name="email" value="<?php echo $email; ?>"></td>
	</tr>
	<tr>
		<td nowrap>Send Email:</td>
		<td nowrap><input type="checkbox" name="sendEmail" value="on" <?php echo $sendEmail; ?>></td>
	</tr>
	<tr>
		<td nowrap>&nbsp;</td>
		<td nowrap>
			<input type="button" value="Submit" onclick="triggerform('submit')" class="enter">
			<input type="button" value="Cancel" onclick="triggerform('cancel')" class="escape">
			<input type="button" value="Password" onclick="triggerform('password')">
		</td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
